package dog_mall_mycenter.service_impl;

import dog_mall_commons.dao.DogsMapper;
import dog_mall_commons.dao.UsersMapper;
import dog_mall_commons.pojo.Dogs;
import dog_mall_commons.pojo.Users;
import dog_mall_mycenter.service.MycenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MycenterServiceImpl implements MycenterService {
    @Autowired
    private UsersMapper usersMapper;

    @Autowired
    private DogsMapper dogsMapper;

    @Override
    public List<Users> findall() {
        return usersMapper.selectAll();
    }

    @Override
    public void insertImg(Dogs dogs) {
        dogsMapper.insertImg(dogs);
    }

    @Override
    public Dogs selectMaxIdForUser(Integer userid) {
        return dogsMapper.selectMaxIdByUserId(userid);
    }

    @Override
    public void updateDogs(Dogs dogs) {
        dogsMapper.updateByPrimaryKey(dogs);
    }

    @Override
    public void updateUserImgById(Integer ids, String originalFilename) {
        usersMapper.updateImgById(ids,originalFilename);
    }

    @Override
    public void UpdateUsernameById(Integer id, String username) {
        usersMapper.updateUsernameById(id,username);
    }

    @Override
    public Users selectuserById(Integer ids) {
        return usersMapper.selectByPrimaryKey(ids);
    }

    @Override
    public void UpdatePwdById(Integer ids, String newPwd1) {
        usersMapper.updatePwdById(ids,newPwd1);
    }

    @Override
    public void updateAddrById(Integer id, String address) {
        usersMapper.updateAddrByID(id,address);
    }

    @Override
    public void deleteAddrById(Integer id) {
        usersMapper.deleteAddrById(id);
    }

    @Override
    public void deleteDogById(Integer id) {
        dogsMapper.deleteByPrimaryKey(id);
    }
}
